package com.demo.config;

import com.demo.service.riot.CleanService;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
@EnableScheduling
public class DataCleanupConfig {

    private final CleanService cleanService;

    public DataCleanupConfig(CleanService cleanService) {
        this.cleanService = cleanService;
    }

    // 每周日凌晨2点清理比赛数据（保留90天）
    @Scheduled(cron = "0 0 2 ? * SUN")
    public void scheduledMatchCleanup() {
        cleanService.cleanupOutdatedMatches(30);
    }

    // 每天凌晨2点清理排位数据（保留30天）
    @Scheduled(cron = "0 0 2 * * ?")
    public void scheduledRankCleanup() {
        cleanService.cleanupOutdatedRankInfo(30);
    }

    // 每天凌晨2点清理不活跃召唤师（保留365天）
    @Scheduled(cron = "0 0 2 * * ?")
    public void scheduledSummonerCleanup() {
        cleanService.cleanupInactiveSummoners(30);
    }
}